<?php
/**
 * Tag.php $id 28 - 2009-10-09 13:51 joao.gsneto
 *
 * Model of Tags
 *
 * JLoja Project
 * @package    models
 * @author     Joao Neto <joao_neto@ymail.com>
 * @version    0.2
 */
class Tag extends BaseTag
{
	/**
	 * Add a tag or array of tags to the database
	 * 
	 * @param array $param			Array of Tag Names
	 * @return Doctrine_Collection		Collection of Inserted Tags
	 */
	public function addTags( $param, $lang = false )
	{
		$arrTags = array();

		if( !is_array( $param ) ){
			$arrTags[] = $param;
		}
		else{
			$arrTags = $param;
		}

		if( !$lang ){
			$lang = JLoja_Lang::getCurrentLang();
		}
		
		$arrTags = new Doctrine_Collection( $this->getTable() );

		foreach( $arrTags as $tag ){
			$tagObj = new Tag();
			$tagObj->Translation[ $lang ]->nm_tag = $tag;

			$tagObj->save();

			$arrTags[] = $tagObj;
		}

		return $arrTags;
	}

}